// 面试题 16.10. 生存人数

function maxAliveYear(birth: number[], death: number[]): number {
    let years = new Array<number>(102).fill(0)
    for(let i=0;i<birth.length;i++){
        years[birth[i]-1900]++
        years[death[i]+1-1900]--
    }
    let prefix = 0
    let max = 0
    let maxYear =0
    for(let i=0 ;i<years.length;i++){
        prefix+=years[i]
        if(prefix>max){
            maxYear=i
            max = prefix
        }
    }
    return maxYear+1900
};